import { defineStore } from "pinia";
import request from '@/API/entry'
import TypeSum from '@/TypeSum/entry'

type AxiosData = TypeSum['AxiosData']['AxiosData']

type storeData = {
    sendCodeData: number | string
}
export const useRegistStore = defineStore('RegistStore', {
    state(): storeData {
        return {
            sendCodeData: '验证码将会自动读取'
        }
    },
    getters: {},
    actions: {
        async getSendCodeData(phoneNumber: number) {
            const result = await request.ApiRequest.reqSendCode(phoneNumber) as AxiosData
            console.log(result)
            if (result.code === 200) {
                this.sendCodeData = result.data
            }
        },
        async getRegister(data: { phone: number, password: string, code: number }) {
            const result = await request.ApiRequest.reqRegister(data) as AxiosData
            if (result.code) {
                return true
            }
        }
    }
}) 